using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace AAM
{
    public class DatabaseRow : Attribute
    {

        public static List<DatabaseRow> GetDatabaseRows(Type type,ref List<PropertyInfo> listProperties)
        {
            PropertyInfo[] properties = type.GetProperties();
            List<DatabaseRow> list = new List<DatabaseRow>();
            foreach (PropertyInfo property in properties)
            {
                object[] attributes = property.GetCustomAttributes(typeof(DatabaseRow), false);
                if (attributes != null && attributes.Length > 0)
                {
                    string name = property.Name;
                    listProperties.Add(property);
                    list.Add( (DatabaseRow)attributes[0] );
                }
            }
            return list;
        }

        private string rowName = null;
        private bool primaryKey = false;
        private bool identity = false;
        private int primaryKeyIndex = 0;
        private string foreignKeyType = "";

        public string RowName
        {
            get { return rowName; }
            set { rowName = value; }
        }
        public bool PrimaryKey
        {
            get { return primaryKey; }
            set { primaryKey = value; }
        }
        public bool Identity
        {
            get { return identity; }
            set { identity = value; }
        }
        public int PrimaryKeyIndex
        {
            get { return primaryKeyIndex; }
            set { primaryKeyIndex = value; }
        }
        public string ForeignKeyType
        {
            get { return foreignKeyType; }
            set { foreignKeyType = value; }
        }

    }
}
